<?php
/**
 * 签到表模型
 */
namespace app\admin\model;

use daswork\Model;

class Attenders extends Model
{
    public function __construct($tablename = '')
    {
        parent::__construct();
        // if ($tablename) {
        //     $this->tablename = $tablename;
        // } else {
        //     $this->tablename = uncamelize(basename(__CLASS__));
        // }
        $this->tablename = 'attenders';
    }

    public function dataList($where = '')
    {
        $sql = "select id,truename,organization,position,sex,phone,email,fee_type,is_report,report_title,hotel_type,room_type,is_share,pay_type,is_pay,money,tax_type,tax_title,tax_number,bank_account,company_address,company_phone,mailing_address,postcode,remark,create_time from $this->tablename $where;";
        // echo $sql;
        // exit;
        return $this->select($sql);
    }

    public function getByTruenameAndPhone($name = '', $phone = '')
    {
        $query = "select * from attenders where truename='$name' and phone='$phone'";
        $result = $this->query($query)->fetch_assoc();
        return $result;
    }

    /**
     * deleteByIds
     */
    public function deleteById($id)
    {
        if (is_array($id)) {
            $sql = "DELETE FROM `$this->tablename` WHERE `id` IN(";
            for ($i=0; $i < count($id); $i++) {
                $sql .= $id[$i] . ',';
            }
            $sql = rtrim($sql, ',');
            $sql .= ");";
        } else {
            $sql = "DELETE FROM `$this->tablename` WHERE `id`=$id;";
        }
        return $this->query($sql);
    }

    public function exportToExcel()
    {

    }
}
